package com.third.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.third.entity.InboundOrder;
import com.third.entity.InboundResult;
import org.apache.ibatis.annotations.*;

import java.util.HashMap;
import java.util.List;

@Mapper
public interface InBoundMapper extends BaseMapper<InboundOrder>{

    @Select("<script>"+
            "select *,b.brand_id "+
            "from inbound_order o,brand b,user u"+
            "<where>"+
            "o.supplier_id=u.user_id and o.brand_id=b.brand_id "+
            "<if test='brandName !=null and brandName!=\"\"'>"+
            "and b.brand_name like CONCAT('%', #{brandName}, '%') "+
            "</if>"+
            "<if test= 'userName !=null and userName!=\"\"'>"+
            "and u.username like CONCAT('%', #{userName}, '%') "+
            "</if>"+
            "<if test= 'orderId !=null and orderId!=\"\"'>"+
            "and o.order_id like CONCAT('%', #{orderId}, '%')  "+
            "</if>"+
            "</where>"+
            " ORDER BY o.order_id "+
            "limit #{start},#{size}"+
            "</script>")
    @Results({
            @Result(property = "orderId",column = "order_id"),
            @Result(property = "orderDate",column = "order_date"),
            @Result(property = "username",column = "username"),
            @Result(property = "userId",column = "user_id"),
            @Result(property = "supplierId",column = "supplier_id"),
            @Result(property = "brandId",column = "brand_id"),
            @Result(property = "brandName",column = "brand_name"),
            @Result(property = "specification",column = "specification"),
            @Result(property = "perice",column = "perice"),
            @Result(property = "quantity",column = "quantity"),
            @Result(property = "permission",column = "permission")
    })
    List<InboundResult> getList(HashMap<String,Object> map);




    /*@Select("SELECT order_id,order_date,username,brand_name,inbound_order.specification,quantity,inbound_order.price,permission FROM inbound_order\n" +
            "LEFT JOIN User ON supplier_id = user_id\n" +
            "LEFT JOIN Brand ON inbound_order.brand_id = brand.brand_id")
    List<InboundResult> selectAll();*/


}
